import java.nio.charset.IllegalCharsetNameException;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author Fizz Pu
 * @Date 2021/7/31 下午7:39
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */

// [][[]2]3

import java.nio.charset.IllegalCharsetNameException;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author Fizz Pu
 * @Date 2021/7/31 下午7:39
 * @Version 1.0
 * 失之毫厘，缪之千里！
 */

// [][[]2]3

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String string = scanner.nextLine();
        char[] chars = string.toCharArray();
        Main main = new Main();
        System.out.println(main.helper(chars, 0, chars.length - 1));
    }


    public int helper(char[] chars, int start, int end) {
        int ret = 0;
        if (start >= end) {
            return 0;
        }

        int newStart = start;
        int newEnd = start;
        int count = 0;
        if (!(chars[start] >= '0' && chars[start] <= '9')) {
            while (newEnd <= end) {
                if (chars[newEnd] == '[') {
                    count++;
                }

                if (chars[newEnd] == ']') {
                    count--;
                }

                if (count == 0) {
                    break;
                }
                newEnd++;
            }

            // []3[]
            if (newEnd + 1 <= end) {
                if (chars[newEnd + 1] >= '0' && chars[newEnd + 1] <= '9') {
                    ret += (chars[newEnd + 1] - '0') + (chars[newEnd + 1] - '0') * helper(chars, newStart + 1, newEnd - 1)
                            + helper(chars, newEnd + 2, end);
                } else {
                    ret += 1 + helper(chars, newStart + 1, newEnd - 1) + helper(chars, newEnd + 1, end);
                }
                return ret;
            } else {
                return 1 + helper(chars, newStart + 1, newEnd - 1);
            }
        }
        return 0;
    }
}